#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

class A
{
public:
	A(int a,int b):_b(b),
		_a(a)
	{

	}

	int _a;
	int _b;

};

template<class T>
void Swap(T& x, T& y)
{
	T tmp = x;
	x = y;
	y = tmp;
}

template<typename A>
A Add(const A& a, const A& b)
{
	return a + b;
}

int main()
{
	int a1 = 10, a2 = 20;
	double d1 = 10.11, d2 = 20.22;
	cout << Add(a1, a2) << endl;
	cout << Add(d1, d2) << endl;
	cout << Add(a1, (int)d2) << endl;
	cout << Add((double)a1, d2) << endl;


	cout << Add<int>(a1, d2) << endl;
	cout << Add<double>(a1, d2) << endl;

	/*int a = 5, b = 9;
	swap(a, b);
	cout << "a = " << a << "b = " << b << endl;
	double c = 1.1, d = 2.5;
	Swap(c, d);
	cout << " c= " << c << "d = " << d << endl;*/
	/*int* p1 = new int(10);
	A* p4 = (A*)malloc(sizeof(int));
	if (p4 == NULL)
	{
		perror("malloc fail:");
	}
	new(p4)A(5,6);
	cout << "p4->_a = " << p4->_a << " p4->_b = " << p4->_b << endl;
	int* p2 = new int[10];
	int* p3 = new int[10] {1, 2, 3, 4};
	A aa = { 1,2 };
	cout << "aa._a = " << aa._a<<" aa._b = " << aa._b << endl;
	return 0;*/
}